<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of tt_xtr</title>
  <meta name="keywords" content="tt_xtr">
  <meta name="description" content="The X_s coordinate in the transposed QTT permutation of indices">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html v1.5 &copy; 2003-2005 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../../index.html">Home</a> &gt;  <a href="#">tt2</a> &gt; <a href="index.html">exp</a> &gt; tt_xtr.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../../index.html"><img alt="<" border="0" src="../../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for tt2/exp&nbsp;<img alt=">" border="0" src="../../right.png"></a></td></tr></table>-->

<h1>tt_xtr
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>The X_s coordinate in the transposed QTT permutation of indices</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>function [x]=tt_xtr(L,K,s) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre class="comment">The X_s coordinate in the transposed QTT permutation of indices
   [X]=TT_XTR(L,K,S)Computes QTT-representation of the vector X_s in the
   transposed permutation with 2^L points in each mode 
   and K variables. Ranks are still 2 here.


 TT-Toolbox 2.2, 2009-2012

This is TT Toolbox, written by Ivan Oseledets et al.
Institute of Numerical Mathematics, Moscow, Russia
webpage: http://spring.inm.ras.ru/osel

For all questions, bugs and suggestions please mail
ivan.oseledets@gmail.com
---------------------------</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="../../tt2/@tt_tensor/tt_tensor.html" class="code" title="function t = tt_tensor(varargin)">tt_tensor</a>	TT-tensor constructor</li></ul>
This function is called by:
<ul style="list-style-image:url(../../matlabicon.gif)">
</ul>
<!-- crossreference -->



<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [x]=tt_xtr(L,K,s)</a>
0002 <span class="comment">%The X_s coordinate in the transposed QTT permutation of indices</span>
0003 <span class="comment">%   [X]=TT_XTR(L,K,S)Computes QTT-representation of the vector X_s in the</span>
0004 <span class="comment">%   transposed permutation with 2^L points in each mode</span>
0005 <span class="comment">%   and K variables. Ranks are still 2 here.</span>
0006 <span class="comment">%</span>
0007 <span class="comment">%</span>
0008 <span class="comment">% TT-Toolbox 2.2, 2009-2012</span>
0009 <span class="comment">%</span>
0010 <span class="comment">%This is TT Toolbox, written by Ivan Oseledets et al.</span>
0011 <span class="comment">%Institute of Numerical Mathematics, Moscow, Russia</span>
0012 <span class="comment">%webpage: http://spring.inm.ras.ru/osel</span>
0013 <span class="comment">%</span>
0014 <span class="comment">%For all questions, bugs and suggestions please mail</span>
0015 <span class="comment">%ivan.oseledets@gmail.com</span>
0016 <span class="comment">%---------------------------</span>
0017 
0018 d=L*K;
0019 r=2*ones(d+1,1);
0020 r(1)=1;
0021 r(d+1)=1;
0022 n=2*ones(d,1);
0023 ps=cumsum([1;n.*r(1:d).*r(2:d+1)]);
0024 <span class="comment">%cr=ones(ps(d+1)-1);</span>
0025 x0=zeros(1,2,2);
0026 x0(:,1,:)=[0,1];
0027 x0(:,2,:)=[0,1];
0028 cr(ps(1):ps(2)-1)=x0(:);
0029 x0=zeros(2,2,1);
0030 x0(:,1,:)=[1;0];
0031 x0(:,2,:)=[1;0];
0032 cr(ps(d):ps(d+1)-1)=x0(:);
0033 <span class="keyword">for</span> i=2:d-1
0034    x0=zeros(2,2,2);
0035    x0(:,1,:)=eye(2);
0036    x0(:,2,:)=eye(2);
0037    cr(ps(i):ps(i+1)-1)=x0(:);
0038 <span class="keyword">end</span>
0039 x=<a href="../../tt2/@tt_tensor/tt_tensor.html" class="code" title="function t = tt_tensor(varargin)">tt_tensor</a>;
0040 
0041 <span class="comment">%Now distribute them in right places: the cores in the</span>
0042 <span class="comment">%transposed permutation are with numbers K*(i-1)+s, i=1,...,L</span>
0043 
0044 <span class="keyword">for</span> i=1:L
0045    curI=K*(i-1)+s;
0046    <span class="keyword">if</span> ( curI ~= 1 &amp;&amp; curI ~= d )
0047       x0=zeros(2,2,2);
0048       x0(:,1,:)=[1,0;0,1];
0049       x0(:,2,:)=[1,0;2^(i-1),1];
0050    <span class="keyword">elseif</span> ( curI == 1 )
0051       x0=zeros(1,2,2);
0052       x0(:,1,:)=[0,1];
0053       x0(:,2,:)=[2^(i-1),1];
0054    <span class="keyword">else</span>
0055       x0=zeros(2,2,1);
0056       x0(:,1,:)=[1;0];
0057       x0(:,2,:)=[1;2^(i-1)]; 
0058    <span class="keyword">end</span>
0059    cr(ps(curI):ps(curI+1)-1)=x0(:);
0060 <span class="keyword">end</span>
0061 
0062 
0063 
0064 x.d=d;
0065 x.n=n;
0066 x.ps=ps;
0067 x.core=cr;
0068 x.r=r;
0069 <span class="keyword">end</span></pre></div>
<hr><address>Generated on Wed 08-Feb-2012 18:20:24 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
</body>
</html>